<template>

    <view class="patient" v-for="(item ,index) in patientData" :key="index"
        @click="selectPeople(item.name,item.id_card)">
        <view class="name">
            <text>{{item.name}}</text>
            <text>{{item.relation}}</text>
        </view>
        <view class="information">
            <text>{{item.sex}}</text>
            <text>{{item.age}}岁</text>
            <text>{{item.phone}}</text>
        </view>
    </view>
    <view style="height:400rpx"></view>
    <view class="form">
        <view class="submit">
            <text @click="canCel">取消</text>
            <text @click="addPatient">添加就诊人</text>
        </view>
    </view>
    <Point :show="show" title="暂无就诊人"></Point>
</template>
<script setup lang="ts">
import Point from '@/pages/common/point.vue';
import { Mypatient } from '@/public/decl-type';
import RequestApi from '@/public/request';
import { onShow } from '@dcloudio/uni-app';
import { ref } from 'vue';
import { myData } from '@/stroe/index'
let patientData = ref<Mypatient[]>([]);
let show = ref<boolean>(false)
const store = myData()
//添加就诊人
function addPatient() {
    uni.navigateTo({
        url: "/pages/addpatient/index"
    })
}
//取消
function canCel() {
    uni.navigateBack();
}
//选择就诊人并返回上一页
function selectPeople(name: string, _id: string) {
    let obj = { name, _id }
    store.addPatient(obj);
    uni.navigateBack();
}
onShow(() => {
    //获取就诊人信息
    uni.showLoading({
        title: "获取就诊人信息",
        mask: true
    })
    RequestApi.GetpaTient().then((res: any) => {
        patientData.value = res.data.data;
        show.value = patientData.value.length > 0 ? false : true;
        uni.hideLoading()
    })
})
</script>
<style lang="scss">
page {
    background-color: #f7f7f7;
}

.patient {
    padding: 10rpx 15rpx;
    background-color: #ffffff;
    margin-bottom: 10rpx;

    .name {
        display: flex;
        align-items: center;

        text:nth-of-type(1) {
            font-size: 30rpx;
            font-weight: bold;
            margin-right: 10rpx;

        }

        text:nth-of-type(2) {
            font-size: 25rpx;
            color: #78beff;
            background-color: #d6f3ff;
            padding: 8rpx 15rpx;

        }
    }

    .information {
        display: flex;
        align-items: center;
        margin-top: 20rpx;


        text {
            font-size: 25rpx;
            color: #7c96af;
            margin-right: 15rpx;
        }
    }

}
</style>